home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 5320 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.9 KB

  1. Path: news.global1.net!news
  2. From: youngrc@global1.net
  3. Newsgroups: comp.lang.c
  4. Subject: Variable blocks of binary data with VAX C?
  5. Date: 10 Feb 1996 01:44:51 GMT
  6. Organization: CMA Consulting Services
  7. Message-ID: <4fgtaj$cne@news.global1.net>
  8. NNTP-Posting-Host: ppp8.global1.net
  9. X-Newsreader: SPRY News 3.03 (SPRY, Inc.)
  10.  
  11.  
  12. The VAX C program is supposed to create an IBM formatted tape. 
  13. The tape has to have a few header files, a tape mark, the EBCDIC
  14. data, a tape mark and a couple trailer records.  The first two
  15. bytes of each block are the blocksize.  The first two bytes of
  16. each record are the record size.  The records are variable
  17. length.  The maximum size of each block is 15,004.
  18.  
  19. The VAX C program reads the EBCDIC records from a file using
  20. fscanf(), appends the record to the record size, and stores it in
  21. a character array until it gets close to the maximum block size. 
  22. When the block is the correct size, the VAX C program appends the
  23. block to the blocksize and writes the EBCDIC character array to
  24. the tape using fputc().  And so on...
  25.  
  26. It is possible for the block of data to contain a <LF> (0Ax)
  27. character.  When VAX C program opens the tape file WITHOUT the
  28. "b" option on the fopen(), the VAX C program was writing a <LF>
  29. (0Ax) to the tape to end one variable length block and start the
  30. next.  Of course, when there was a <LF> (0Ax) character IN the
  31. block of data that VAX C program was writing, the block on the
  32. tape would end and a new one would start.  This is not correct.
  33.  
  34. When VAX C program opens the tape file WITH the "b" option on the
  35. fopen(), the <LF> (0Ax) character in the block of data can be
  36. written as data.  Now the VAX C program has no way to end a
  37. variable length block and start the next.  
  38.  
  39. Using the "b" option on the fopen() allows the VAX C program to
  40. write escape characters to the tape (which has to be done),  but
  41. how is the end of block specified?
  42.  
  43.  
  44.  
  45.  
  46.  
  47.  
  48. Ron Young
  49. Consultant
  50. CMA Consulting Services
  51. youngrc@global1.net
  52.  
  53.  
  54.